package com.example.test;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.util.Log;
import android.view.View;

import com.a.l.JwtDomain;
import com.a.l.JwtServerDomain;
import com.a.l.KonkeServer;

import org.json.JSONException;
import org.json.JSONObject;

public class MainActivity extends AppCompatActivity {

    private JwtDomain mJwtDomain;
    private JwtServerDomain mJwtServerDomain;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);


    }

    public void push(View view) {
        JwtServerDomain.getInstance(this).update();
    }

    public void init(View view) {
        try {
            SharedPreferences sp = getSharedPreferences(
                    "FlutterSharedPreferences",
                    Context.MODE_MULTI_PROCESS);
            SharedPreferences.Editor edit = sp.edit();
            JSONObject object = new JSONObject();
            object.put("authCode", "AF06FF46");
            object.put("qrcode", "KONKE-CCU:21:150321:A86FA1DDFCAD3BF76E41421CFF3ED02E");
            object.put("deviceId", "CCU_150321");
            object.put("accessToken", "1e06b90231835f47d5a3890a341c3bea");
            edit.putString("flutter.jwt_current_ccu", object.toString()).commit();
        } catch (JSONException e) {
            e.printStackTrace();
        }
    }

    public void holle(View view) {
                startService(new Intent(this, KonkeServer.class));
        sendBroadcast(new Intent("ikonkeAidlStart"));
        Log.e("tag", "发送广播");
    }
}